var e = require("../../@babel/runtime/helpers/interopRequireDefault"), a = e(require("../../@babel/runtime/regenerator")), t = require("../../@babel/runtime/helpers/toConsumableArray"), r = require("../../@babel/runtime/helpers/asyncToGenerator"), s = e(require("../../utils/api")), i = getApp();

Page({
    data: {
        statusBarHeight: i.globalData.statusBarHeight,
        resourceUrl: i.globalData.resourceUrl,
        pageNum: 1,
        pageSize: 30,
        list: [],
        more: !0,
        tip: "下拉刷新更多内容",
        cardList: [],
        cardPageNum: 1,
        cardPageSize: 30,
        cardMore: !0,
        cardTip: "下拉刷新更多内容",
        rankType: 0
    },
    switchRankType: function(e) {
        this.data.rankType != e.target.dataset.current && this.setData({
            rankType: Number(e.target.dataset.current)
        });
    },
    getList: function() {
        var e = this;
        return r(a.default.mark(function r() {
            var i, n, u;
            return a.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    return i = wx.getStorageSync("openid"), a.prev = 1, a.next = 4, s.default.rankRecord({
                        openid: i,
                        pageNum: e.data.pageNum,
                        pageSize: e.data.pageSize
                    });

                  case 4:
                    n = a.sent, (u = e.data.list).push.apply(u, t(n.result.list)), e.setData({
                        list: u
                    }), n.result.list.length < e.data.pageSize && e.setData({
                        more: !1,
                        tip: "没有更多了"
                    }), a.next = 14;
                    break;

                  case 11:
                    a.prev = 11, a.t0 = a.catch(1), console.log(a.t0.msg);

                  case 14:
                  case "end":
                    return a.stop();
                }
            }, r, null, [ [ 1, 11 ] ]);
        }))();
    },
    getCardList: function() {
        var e = this;
        return r(a.default.mark(function r() {
            var i, n, u;
            return a.default.wrap(function(a) {
                for (;;) switch (a.prev = a.next) {
                  case 0:
                    return i = wx.getStorageSync("openid"), a.prev = 1, a.next = 4, s.default.cardRankRecord({
                        openid: i,
                        pageNum: e.data.cardPageNum,
                        pageSize: e.data.cardPageSize
                    });

                  case 4:
                    n = a.sent, (u = e.data.cardList).push.apply(u, t(n.result.list)), e.setData({
                        cardList: u
                    }), n.result.list.length < e.data.cardPageSize && e.setData({
                        cardMore: !1,
                        cardTip: "没有更多了"
                    }), a.next = 14;
                    break;

                  case 11:
                    a.prev = 11, a.t0 = a.catch(1), console.log(a.t0.msg);

                  case 14:
                  case "end":
                    return a.stop();
                }
            }, r, null, [ [ 1, 11 ] ]);
        }))();
    },
    onShow: function() {
        this.setData({
            tip: "下拉刷新更多内容",
            pageNum: 1,
            pageSize: 30,
            list: [],
            more: !0,
            cardList: [],
            cardPageNum: 1,
            cardPageSize: 30,
            cardMore: !0,
            cardTip: "下拉刷新更多内容"
        }), this.getList(), this.getCardList();
    },
    onReachBottom: function() {
        0 == this.data.rankType ? this.data.more && (this.setData({
            pageNum: ++this.data.pageNum
        }), this.getList()) : this.data.cardMore && (this.setData({
            cardPageNum: ++this.data.cardPageNum
        }), this.getCardList());
    },
    onShareAppMessage: function() {
        return {
            title: "排行榜开启了 快来参加吧！",
            path: "/pages/index/index"
        };
    }
});